<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./template/VisitorTemplate.xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:define name="contentInsert">   
        <h:body>
            <h:form id="formMain">

                <p:panel id="panel">
                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>
                    <p:messages />
                    <h:panelGrid>
                        <h:outputText value="Date booked: #{reservationManagerBean.getReservedDate()}"/>   
                        <h:outputText  value="Number of people: #{reservationManagerBean.reservation.noOfPeople}" /> 
                        <h:outputText  value="Time Booked: #{reservationManagerBean.getReservedTime()}" />                     
                    </h:panelGrid>
                    <h1>Table selected</h1>
                    <p:dataTable id="test" var="table" value="#{reservationManagerBean.selectedTable}" 
                                 rowIndexVar="row" >
                        <p:column headerText="Name">
                            <h:outputText value="#{table.name}" />
                        </p:column>

                        <p:column headerText="Picture">
                            <h:graphicImage id="gi" alt="The image could not be found."   value="/images/#{table.imageURL}" width="250" height="250"></h:graphicImage>
                        </p:column>
                        <p:column headerText="Description">
                            <h:outputText value="#{table.description}" />
                        </p:column>

                        <p:column headerText="Number of seats">
                            <h:outputText value="#{table.unitCapacity}" />
                        </p:column>

                        <p:column headerText="Num of table selected">
                            <h:outputText  value="#{reservationManagerBean.selectedTableQuantity.get(row)}" />   
                        </p:column>
                    </p:dataTable>

                    <p:panel id="menu" header="Your menu" style="width:400px; height: 600px; position: relative; left: 500px; float:none;">  
                        <c:forEach items="#{reservationManagerBean.listOfFoodType}" var="food" varStatus="current">
                            <h:outputText value="#{food.name}" styleClass="menu"/>
                            <p:dataList rendered="#{reservationManagerBean.choiceList.size() > current.index}" value="#{reservationManagerBean.choiceList.get(current.index)}" var="selectedMeal" type="ordered" style="width:400%">  
                                #{selectedMeal.name} 
                            </p:dataList> 
                        </c:forEach>
                        <h:outputText value="Set Meal" styleClass="menu" />
                        <p:dataList value="#{reservationManagerBean.choiceList.get(reservationManagerBean.listOfCategory.size()-1)}" var="selectedProduct" type="ordered" style="width:400%">  
                           #{selectedProduct.name}  
                        </p:dataList> 
                        <div style="position:absolute; bottom:0px; float:none; text-align: justify">
                            <h:outputText value="Total offline bill: " />
                            <h:outputText value="#{reservationManagerBean.totalBill}" style="font-weight: bold; color:blue;"/>
                            <p>
                                <h:outputText value="Total online bill: " />
                                <h:outputText value="#{reservationManagerBean.discountBill}" style="font-weight: bold; color:red;"/>
                            </p>
                            <p>
                                <h:outputText value="You Save:" />
                                <h:outputText value="#{reservationManagerBean.totalBill - reservationManagerBean.discountBill}" style="font-weight: bold; color:purple;"/>
                            </p>

                            <p:inputTextarea value="#{reservationManagerBean.reservation.specialRequest}" effectDuration="400" rendered="#{!reservationManagerBean.finish}"/>
                            <h:outputText value="#{reservationManagerBean.reservation.specialRequest}" rendered="#{reservationManagerBean.finish}"/> 
                            <p:commandButton id="btn" value="Make Reservation" update="panel"  actionListener="#{reservationManagerBean.makeReservation}" rendered="#{!reservationManagerBean.finish}"/>
                        </div>
                    </p:panel>                   
                </p:panel>
            </h:form>
        </h:body>
    </ui:define>
</ui:composition>